
import 'package:flutter/material.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:oramemo/common/routes/routes.dart';
import 'package:oramemo/generated/assets.dart';
import 'package:oramemo/pages/facility/facility_router.dart';

class ConversationItemWidget extends StatelessWidget {
  const ConversationItemWidget({
    super.key,
    required this.message,
  });

  final Message message;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        Get.toNamed(FacilityRouter.facilityDetails);
      },
      child: Container(
        decoration: const BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(16)),
        ),
        margin: const EdgeInsets.only(top: 12),
        child: Padding(
          padding: const EdgeInsets.all(16),
          child: Row(
            children: [
              IconX.image(
                  message.type == MessageType.incoming
                      ? Assets.facilityTelIn
                      : Assets.facilityTelOut,
                  size: 32),
              const SizedBox(width: 16),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(message.time,
                        style: const TextStyle(
                            fontSize: 16,
                            color: Color(0XFF333333),
                            fontWeight: FontWeight.normal)),
                    const SizedBox(height: 4),
                    Text(message.message,
                        style: const TextStyle(
                            fontSize: 16,
                            color: Color(0XFF777777))),
                  ],
                ),
              ),
              Icon(Icons.chevron_right, color: Colors.grey),
            ],
          ),
        ),
      ),
    );
  }
}

class Message {
  final int id;
  final MessageType type;
  final String time;
  final String message;

  Message(
      {required this.id,
        required this.type,
        required this.time,
        required this.message});
}

enum MessageType { incoming, outgoing }
